package com.xbjtech.ticketsystem.utils.bean;

import lombok.Data;

/**
 * @author leejun.happy@gmail.com
 * @created 2019/2/20
 */

@Data
public class ResponseResult<T> {

    private static final String OK = "ok";
    private static final String ERROR = "error";

    private Boolean success;
    private String message;
    private T data;

    public ResponseResult() {
    }

    public ResponseResult(Boolean success) {
        this.success = success;
    }

    public ResponseResult(Boolean success, String message) {
        this.success = success;
        this.message = message;
    }

    public ResponseResult<T> success() {
        this.success = true;
        this.message = OK;
        return this;
    }

    public ResponseResult<T> success(T data) {
        this.success().data = data;
        return this;
    }

    public ResponseResult<T> failure() {
        this.success = false;
        this.message = ERROR;
        return this;
    }

    public ResponseResult<T> failure(T data) {
        this.success().data = data;
        return this;
    }
}
